import watchdog from "../dxmodules/dxWatchdog.js";
import gpio from "../dxmodules/dxGpio.js"
import std from "../dxmodules/dxStd.js"
import logger from '../dxmodules/dxLogger.js'

// id
const id = 'watchdog'

// To use a watchdog timer, GPIO needs to be initialized first.
gpio.init()

// Enable hardware and software watchdogs
watchdog.open(1 | 2, id)

// Create a watchdog
let dog1 = 1
// Enable the watchdog
logger.info(watchdog.enable(dog1, id));// true

// The timeout period is in milliseconds. If the watchdog is not fed, the system will automatically restart after the timeout.
logger.info(watchdog.start(5000, id));// true

// Feed the watchdog with a timer, once per second.
std.setInterval(() => {
    logger.info(watchdog.restart(dog1, id));
}, 1000)

